<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="Keywords" content="">
	<meta name="Description" content="">
	<title>0531-JS作业1-倒计时跳转-螺旋</title>
	<style type="text/css">
		html {font-family: "Microsoft YaHei";}
		body, p{margin: 0;}
		.wrap{
			width: 300px;
			height: 100px;
			margin: 50px auto;
			border: 2px dashed #006eff;
		}
		.wrap p{
			font-size: 16px;
			line-height: 100px;
			text-align: center;
		}
		.wrap p span{
			color: #f00;
		}
	</style>
</head>
<body>
	<section class="wrap">
		<p><span>10</span> 秒后跳转至 www.baidu.com</p>
	</section>
</body>
<script>
	var oSpan = document.getElementsByTagName('span')[0],
		i = 10;

    setInterval( function(){
		oSpan.innerHTML = i;
        i--;
        if(i === 0){
            window.location.href = "http://www.baidu.com";
        }
    },1000);
</script>
</html>